package April._19.work5;

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        File encodingFile = new File("fileTest\\a.txt");
        File encodedFile = new File("fileTest\\b.txt");
        encodFile(encodingFile,encodedFile);
    }

    private static void encodFile(File encodingFile, File encodedFile) throws IOException {
        FileInputStream in = new FileInputStream(encodingFile);
        byte[] bytes = new byte[1024];
        int readCount=0;
        while((readCount=in.read(bytes))!=-1){
            for (int i = 0; i < readCount; i++) {
                if(!(bytes[i]>=0&&bytes[i]<=9||bytes[i]>=65&&bytes[i]<=90||bytes[i]>=97&&bytes[i]<=122)){
                    continue;
                }
                if(bytes[i]==9){
                    bytes[i]=0;
                }
                if(bytes[i]==90){
                    bytes[i]=65;
                }
                if(bytes[i]==122){
                    bytes[i]=97;
                }
                if(bytes[i]>=0&&bytes[i]<=8||bytes[i]>=65&&bytes[i]<90||bytes[i]>=97&&bytes[i]<122){
                    bytes[i]++;
                }
            }
            FileOutputStream out = new FileOutputStream(encodedFile);
            out.write(bytes,0,readCount);
        }
    }

}
